LeftProjection

data class LeftProjection<out L, out R>(val either: Either<L, R>)

Constructors

Link copied to clipboard
fun <out L, out R> LeftProjection(either: Either<L, R>)

Functions

Link copied to clipboard
inline fun all(predicate: (L) -> Boolean): Boolean

Returns the result of applying the predicate to the value if this is Left or true if this is Right.

Link copied to clipboard
inline fun any(predicate: (L) -> Boolean): Boolean

Returns the result of applying the predicate to the value if this is Left or false if this is Right.

Link copied to clipboard
inline fun filter(predicate: (L) -> Boolean): Either<L, R>?

Returns the same Left if the predicate is satisfied for the value. Otherwise returns null.

Link copied to clipboard
inline fun <T> filterIsInstance(): Either<T, R>?

Returns the same Left casted to type T if it is T. Otherwise returns null.

Link copied to clipboard
inline fun <T> filterIsInstanceToOption(): Option<Either<T, R>>

Returns Some containing the same Left casted to type T if it is T. Otherwise returns None.

Link copied to clipboard
inline fun filterNot(predicate: (L) -> Boolean): Either<L, R>?

Returns the same Left if the predicate is not satisfied for the value. Otherwise returns null.

Link copied to clipboard
inline fun filterNotToOption(predicate: (L) -> Boolean): Option<Either<L, R>>

Returns Some containing the same Left if the predicate is not satisfied for the value. Otherwise returns None.

Link copied to clipboard
inline fun filterToOption(predicate: (L) -> Boolean): Option<Either<L, R>>

Returns Some containing the same Left if the predicate is satisfied for the value. Otherwise returns None.

Link copied to clipboard
inline fun forEach(action: (L) -> Unit)

Runs action if this is a Left. Returns Unit without any action if this is a Right.

Link copied to clipboard
fun get(): L

Gets value of this Left.

Link copied to clipboard
fun getOrNull(): L?

Gets value of this Left or null if this is Right.

Link copied to clipboard
inline fun <T> map(transform: (L) -> T): Either<T, R>

Maps value of this Left using transform.

Link copied to clipboard
inline fun none(predicate: (L) -> Boolean): Boolean

Returns false if the predicate is met by the value if this is Left or true otherwise.

Link copied to clipboard
fun toOption(): Option<L>

Returns a Some containing the Left value if it exists, or a None if this is a Right.

Properties

Link copied to clipboard
val either: Either<L, R>

Extensions

Link copied to clipboard
fun <L, R> LeftProjection<L?, R>.filterNotNull(): Either<L, R>?

Returns the same Left if its value is not null. Otherwise returns null.

Link copied to clipboard
fun <L, R> LeftProjection<L?, R>.filterNotNullToOption(): Option<Either<L, R>>

Returns Some containing the same Left if its value is not null. Otherwise returns None.

Link copied to clipboard
inline fun <L, R> LeftProjection<L, R>.filterOrElse(predicate: (L) -> Boolean, zero: () -> R): Either<L, R>

Returns the same Left if the predicate is satisfied for the value, Right(zero) if the predicate is not satisfied for the value, or the same Right if this is Right.

Link copied to clipboard
inline fun <L, R, T> LeftProjection<L, R>.flatMap(transform: (L) -> Either<T, R>): Either<T, R>

Maps value of this Left to a new Either using transform.

Link copied to clipboard
inline fun <L, R> LeftProjection<L, R>.getOrElse(default: () -> L): L

Gets value of this Left or default value if this is Right.